package cn.tuling.simplefactory;

public class AbstractFactoryMethodTest {
    public static void main(String[] args) {
        AnimalFactory horseFactory = new HorseFactory();
        Animal horse = horseFactory.createAnimal();
        horse.show();

        AnimalFactory cattleFactory = new CattleFactory();
        Animal cattle = cattleFactory.createAnimal();
        cattle.show();
    }

}

interface Animal {
    void show();
}

class Horse implements Animal {

    // 很多成员变量

    public Horse(String param1, String param2, String param3, int param4, Object... params) {
        // .. 很多初始化操作
    }

    @Override
    public void show() {
        System.out.println("我是马");
    }
}

class Cattle implements Animal {
    // 很多成员变量

    public Cattle(String param1, String param2, String param3, int param4, Object... params) {
        // .. 很多初始化操作
    }

    @Override
    public void show() {
        System.out.println("我是牛");
    }
}


interface AnimalFactory {

    Animal createAnimal();
}

class HorseFactory implements AnimalFactory {

    @Override
    public Animal createAnimal() {
        // 简化了马的养育过程
        return new Horse(null, null, null, 0, null);
    }
}

class CattleFactory implements AnimalFactory {

    @Override
    public Animal createAnimal() {
        // 简化了牛的养育过程
        return new Cattle(null, null, null, 0, null);
    }
}



